<html>
<head><meta charset="utf-8"><title>Destructor not called / compiler bug? · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Destructor.20not.20called.20.2F.20compiler.20bug.3F.html">Destructor not called / compiler bug?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="196105981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Destructor%20not%20called%20/%20compiler%20bug%3F/near/196105981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Diggsey <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Destructor.20not.20called.20.2F.20compiler.20bug.3F.html#196105981">(May 03 2020 at 14:34)</a>:</h4>
<p>I found this strange behaviour where a local variable is not dropped when a destructor in the same scope panics: <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=5e68a9ecbb2f4d61fff4faef592c2f07" title="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=5e68a9ecbb2f4d61fff4faef592c2f07">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=5e68a9ecbb2f4d61fff4faef592c2f07</a></p>



<a name="196106048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Destructor%20not%20called%20/%20compiler%20bug%3F/near/196106048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Diggsey <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Destructor.20not.20called.20.2F.20compiler.20bug.3F.html#196106048">(May 03 2020 at 14:36)</a>:</h4>
<p>it seems to only happen if the local will be returned from the function</p>



<a name="196106256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Destructor%20not%20called%20/%20compiler%20bug%3F/near/196106256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Diggsey <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Destructor.20not.20called.20.2F.20compiler.20bug.3F.html#196106256">(May 03 2020 at 14:42)</a>:</h4>
<p>ah there's already an issue <a href="https://github.com/rust-lang/rust/issues/47949" title="https://github.com/rust-lang/rust/issues/47949">https://github.com/rust-lang/rust/issues/47949</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>